<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="_path" value="${pageContext.request.contextPath}"></c:set>
<form id="queryForm" style="margin:10;text-align: center;">
	<table width="100%">
		<tr>
			<td>统计方式：</td>
			<td>
				<label><input id="_timeType_1" type="radio" name="q@timeType" value="1" checked="checked"/>天</label>
				<label><input type="radio" name="q@timeType" value="2" />月</label>
				<label><input type="radio" name="q@timeType" value="3" />年</label>
			</td>
			<td>POS机编码：</td>
			<td>
				<input type="text" name="q@aacid" class="easyui-numberbox" style="width:200px;"/>
			</td>
			<td>商户ID：</td>
			<td>
				<input type="text" name="q@aabid" class="easyui-numberbox" style="width:200px;"/>
			</td>
			<td align="center">
				<a href="javascript:void(0);" onclick="clearForm()" class="easyui-linkbutton" iconCls="icon-search">清空</a>
			</td>
		</tr>
		<tr>
			<td>开始日期：</td>
			<td>
				<input type="input" class="easyui-datebox" style="width:200px;" name="q@timeFrom"/>
			</td>
			<td>结束日期：</td>
			<td>
				<input type="input" class="easyui-datebox" style="width:200px;" name="q@timeTo"/>
			</td>
			<td></td>
			<td>
			</td>
			<td align="center"><a href="javascript:void(0);" onClick="doSearch()" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
		</tr>
	</table>
</form>
<div id="acaSumTable"></div>
<script>
jQuery(function($){
	$('#acaSumTable').datagrid({
		title:'消费统计',//标题
		method:'post',
		iconCls:'icon-edit',//图标
		singleSelect:false,//多选
		height:380, //高度
		fitColumns: true,//自动调整各列，用了这个属性，下面各列的宽度值就只是一个比例。
		striped: true,//奇偶行颜色不同
		collapsible:false,//可折叠
		url:"aca/queryAcaSumList", //数据来源
		sortName: 'timeStr', //排序的列
		sortOrder: 'desc', //倒序
		remoteSort: true, //服务器端排序
		queryParams:{}, //查询条件
		pagination:true, //显示分页
		rownumbers:true, //显示行号
		showFooter:true,
		columns:[[
			//{field:'ck',checkbox:true,width:2}, //显示复选框
			{field:'timestr',title:'时间',width:20,sortable:true},
			{field:'aacid',title:'POS机ID',width:20,sortable:true},
			{field:'aabid',title:'商户ID',width:20,sortable:true},
			{field:'emoneyconsumesum',title:'电子账户消费金额',width:20,sortable:true},
			{field:'emoneyconsumetimesum',title:'电子账户消费次数',width:20,sortable:true},
			{field:'moneyconsumesum',title:'电子钱包消费金额',width:20,sortable:true},
			{field:'moneyconsumetimesum',title:'电子钱包消费次数',width:20,sortable:true},
			{field:'totalconsumesum',title:'总消费金额',width:20,sortable:true},
			{field:'totalconsumetimesum',title:'总消费次数',width:20,sortable:true},
			{field:'fee',title:'手续费',width:20,sortable:true}
		]]/*,
		toolbar:[{
			text:'导出Excel',
			iconCls:'icon-excel',
			handler:function(){
				updaterow();
			}
		},'-']*/,
		onLoadSuccess:function(){
			$('#acaSumTable').datagrid('clearSelections'); //一定要加上这一句，要不然datagrid会记住之前的选择状态，删除时会出问题
		}
	});
});
function updaterow(){
	var rows = $('#acaSumTable').datagrid('getSelections');
	//这里有一个jquery easyui datagrid的一个小bug，必须把主键单独列出来，要不然不能多选
	if(rows.length==0){
		$.messager.alert('提示',"请选择退货的消费记录!",'info');
		return;
	}
	if(rows.length > 1){
		$.messager.alert('提示',"只能选择一个消费记录退货",'info');
		return;
	}
	showWindow({
			title:'消费退货',
			href:'${_path}/aca/acaReturnPopWindow?acaid='+ rows[0].id,
			width:500,
			height:450
		});
}
//表格查询
function doSearch(){
	var params = $('#acaSumTable').datagrid('options').queryParams;//先取得 datagrid的查询参数
	var fields =$('#queryForm').serializeArray();//自动序列化表单元素为JSON对象
	$.each( fields, function(i, field){
		params[field.name] = field.value;//设置查询参数
	}); 
	$('#acaSumTable').datagrid('reload');
}
//清空查询条件
function clearForm(){
	$('#queryForm').form('clear');
	$('#_timeType_1').attr('checked','checked');
	doSearch();
}
</script>